<?php

require_once(dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);

$instance = sfContext::createInstance($configuration);

header("Content-type: text/css");
$css = file_get_contents($_GET['i']);
$css = preg_replace('/\s+/', " ", $css);
$css = preg_replace('/:\s/', ":", $css);

$skip_arr = array(
    'jquery.fancybox-1.3.4.css'
);

if (sfContext::getInstance()->getUser()->getCulture() == 'ar' && $_GET['i'] && !in_array($_GET['i'], $skip_arr)) {

    $css = str_replace('float:left', 'float:yameen', $css);
    $css = str_replace('float:right', 'float:left', $css);
    $css = str_replace('float:yameen', 'float:right', $css);
	
    $css = str_replace('/images/', '/images/ar/', $css);

    $css = str_replace('left:', 'yameen:', $css);
    $css = str_replace('right:', 'left:', $css);
    $css = str_replace('yameen:', 'right:', $css);

    $css = str_replace('text-align:left;', 'text-align:yameen;', $css);
    $css = str_replace('text-align:right;', 'text-align:left;', $css);
    $css = str_replace('text-align:yameen;', 'text-align:right;', $css);

    $css = 'body{direction:rtl;text-align:right;}' . $css;
	
	if($_GET['i'] == 'styles.css'){
	$custom = <<<EOS
.right_top_search_wrap {
    float: right;
}
.left_logo {
    float: left;
	width: 185px;
}
.user_drop_menu li {
    padding: 1px 15px 1px 45px;
}
.add_more {
    background-position: right center;
}
EOS;
	$css = $css.$custom;
	}
}

echo $css;
